package  
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.Timer;
	import flash.system.System;
	
	/**
	 * Класс, выводящий игровой интерфейс.
	 * @author ...
	 */
	public class Interface extends Sprite 
	{
		public var mainRef:Main;
		public var stageRef:Stage;
		
		public var showLife:Boolean=true;
		public var showScores:Boolean=true;
		public var showDodje:Boolean = true;
		public var showDex:Boolean=true;
		
		protected var txtLife:TextField;
		protected var txtDodje:TextField;
		protected var txtScores:TextField;
		protected var txtDex:TextField;
		
		public function Interface(mRef:Main) 
		{
			mainRef = mRef;
			stageRef = mainRef.stage;
			/* Параметры интерфейса */
			
			//stageRef.addChild(this);
			x = 0;
			y = 0;
			//width = stageRef.stageWidth;
			//height = stageRef.stageHeight;
			//var newInterface:Interface = null;
			//newInterface = stageRef.addChild(this);
			//newInterface.x = 0;
			//newInterface.y = 0;
			//newInterface.width = stageRef.stageWidth;
			//newInterface.height = stageRef.stageHeight;
			
			stageRef.addEventListener(Event.ENTER_FRAME, updateInfo);
			
			/* Шрифт */
			var fmtInfoLabels:TextFormat = new TextFormat();
			fmtInfoLabels.size = 20;
			
			/* Контролы отображения*/
			txtLife = new TextField();
			txtLife.type = "dynamic";
			addChild(txtLife);
			txtLife.defaultTextFormat = fmtInfoLabels;
			txtLife.x = 10;
			txtLife.y = 100;
			txtLife.text = System.totalMemory.toString();
			txtLife.wordWrap = false;
			txtLife.textColor = 0xFF9999;
			
			//txtDodje = new TextField();
			//addChild(txtDodje);
			//txtDodje.defaultTextFormat = fmtInfoLabels;
			//txtDodje.x = 10;
			//txtDodje.y = stageRef.stageHeight - 70;
			
			//txtScores = new TextField();
			//addChild(txtScores);
			//txtScores.defaultTextFormat = fmtInfoLabels;
			//txtScores.x = 10;
			//txtScores.y = stageRef.stageHeight - 40;
			
			txtDex = new TextField();
			txtDex.type = "dynamic";
			addChild(txtDex);
			txtDex.defaultTextFormat = fmtInfoLabels;
			txtDex.x = 10;
		    txtDex.y = stageRef.stageHeight - 15;
			txtDex.textColor = 0xFF9999;
			txtDex.wordWrap = false;
		}
		
		private function updateInfo(e:Event):void
		{
			if (showLife)
			{
				txtLife.text = "Lifzz:";
			}
			
			if (showDex)
			{
				txtDex.text = "Dex:";
			}
			
			//if (showScores)
			//{
				//txtScores.text = "Scores:";
			//}
			//
			//if (showDodje)
			//{
				//txtDodje.text = "Dodjes:";
			//}
		}
	}

}